package cn.edu.dz.Tread;

public class MyThread  extends Thread {
    //终止变量
    private boolean stopped;
    private String Name;

    public MyThread(String name) {
        super(name) ;
    }

    @Override

    public void run() {
        int i = 0;
        //没有写循环因子，是死循环
        for (; ; ) {
            try {
                //多线程业务处理
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

                System.out.println(this.getName() + ":" + i++);
            //判断是否需要终止线程
            if (stopped) {
                    break;
                }
            }
        }


    public boolean isStopped() {
        return stopped;
    }

    public void setStopped(boolean stopped) {
        this.stopped = stopped;
    }

    /*@Override
    public String getName() {
        return Name;
    }

    @Override
    public void setName(String name) {
        Name = name;
    }
    */
}



